<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>CruiseControl.NET : Scenario One</title>
	    <link rel="stylesheet" href="styles/site.css" type="text/css" />
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">	    
    </head>

    <body>
	    <table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
		    <tr>
			    <td valign="top" class="pagebody">
				    <div class="pageheader">
					    <span class="pagetitle">
                            CruiseControl.NET : Scenario One
                                                    </span>
				    </div>
				    <div class="pagesubheading">
					    This page last changed on Jun 27, 2009 by <font color="#0050B2">csut017</font>.
				    </div>

				    

<h3><a name="ScenarioOne-Scenario%231%3ASmallInhouseDevelopmentTeam"></a>Scenario #1: Small In-house Development Team</h3>

<h4><a name="ScenarioOne-Background"></a>Background	</h4>

<p>The company is Acme Insurance, the company that provides development insurance for software houses. Bob leads a team of six people - three developers, a business analyst (BA) and a couple of testers. The systems they develop are in-house systems for the company - and consists of a couple of Windows applications plus an internal intranet web application.</p>

<p>Bob wants to secure their installation of CruiseControl.Net so he knows what is happening and to limit access to certain projects.</p>

<h4><a name="ScenarioOne-TheBuildSetup"></a>The Build Setup</h4>

<p>Each application (two windows apps, plus one web app) has three projects in CruiseControl.Net. Additionally there are a few smaller projects for common libraries - which are used by the main applications - bringing the total number of projects to twelve.</p>

<p>Each application, plus the libraries, have a simple compile-and-test build project. This projects ensures that the code builds, the local unit tests run and the successful outputs are copied to a central "store" for the executables. These are triggered on an interval basis (when code is checked in) or via a force build.</p>

<p>The applications also have two deploy projects each - deploy to QA and deploy to PROD. These generate "production" builds, copy all the executables and related files into deployment packages and copy them to the staging area. Additionally the web application is automatically deployed to either the QA or pre-PROD servers. The QA versions run overnight, the PROD versions must be manually triggered.</p>

<p>So despite this being a small team, there are still a fair number of projects, plus some can potentially screw up processes (either QA or PROD).</p>

<h4><a name="ScenarioOne-TheGoals"></a>The Goals</h4>

<p>The twelve projects can be divided into three security zones: low, medium and high. The following table helps to define these three zones:</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Zone </th>
<th class='confluenceTh'> Description </th>
<th class='confluenceTh'> Projects </th>
<th class='confluenceTh'> People </th>
</tr>
<tr>
<td class='confluenceTd'> Low </td>
<td class='confluenceTd'> Projects that everybody can access </td>
<td class='confluenceTd'> Compile-and-test projects (six) </td>
<td class='confluenceTd'> Everybody </td>
</tr>
<tr>
<td class='confluenceTd'> Medium </td>
<td class='confluenceTd'> Projects that need to limit access </td>
<td class='confluenceTd'> Deploy to QA projects (three) </td>
<td class='confluenceTd'> Team lead, BA and testers </td>
</tr>
<tr>
<td class='confluenceTd'> High </td>
<td class='confluenceTd'> Projects that can affect production </td>
<td class='confluenceTd'> Deploy to PROD projects (three) </td>
<td class='confluenceTd'> Team lead and BA </td>
</tr>
</tbody></table>

<p>For low security, they don't really care what happens to the projects - it is the entire responsibility of the team. While this can still lead to an abuse of trust, the consequences would be reasonably minor.</p>

<p>As the security needs increase, the consequences of someone screwing things up (either deliberately or by accident) increases. Damaging the QA environment could lead to a loss of one or more days work by the testers and the BA - not serious consequences but potentially a large waste of time and resources. Damaging PROD would lead to a serious waste of time, plus potentially damage the company's client-relationships.</p>

<h4><a name="ScenarioOne-ThePlan"></a>The Plan</h4>

<p>With these goals in mind, this gives two actual levels of security. The first level is unsecured - anyone can do anything to the projects and there is no real need to audit anything. This is very similar to how CC.Net currently works.</p>

<p>The security level limits who can access and modify projects in CC.Net. Within this level there are two groups - testers and releasers. Membership to the testers group allows full access to the deploy to QA projects, while the releasers group allows access to all deployment projects.</p>

<p>This definition gives a very simple design - two roles with two users in each. Six projects need security, while the other six do not. Since the users need to be secured they will use passwords (to ensure the other people don't "use" their user name). Finally, all deployments will be audited to assess the effectiveness of security in the long run.</p>

<p>The following diagram shows how I'm going to implement the security:<br/>
<img src="download/attachments/28868718/Scenario1Overview.jpg" align="absmiddle" border="0"/></p>

<h4><a name="ScenarioOne-TheConfiguration"></a>The Configuration</h4>

<p>Since I'm looking at the security, not the actual projects, I'm going to use the following general configuration for each project:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;project name=<span class="code-quote">"WinApp1-Build"</span>&gt;</span>
  <span class="code-tag">&lt;workingDirectory&gt;</span>C:\Build\WinApp1-Build<span class="code-tag">&lt;/workingDirectory&gt;</span>
  <span class="code-tag">&lt;artifactDirectory&gt;</span>C:\Build\WinApp1-Build\Deploy<span class="code-tag">&lt;/artifactDirectory&gt;</span>
  <span class="code-tag">&lt;webURL&gt;</span>http://localhost/server/local/project/WinApp1-Build/ViewProjectReport.aspx<span class="code-tag">&lt;/webURL&gt;</span>
  <span class="code-tag">&lt;triggers&gt;</span>
    <span class="code-tag">&lt;intervalTrigger buildCondition=<span class="code-quote">"IfModificationExists"</span> seconds=<span class="code-quote">"300?/&gt;</span>"</span>
  <span class="code-tag">&lt;/triggers&gt;</span>
  <span class="code-tag">&lt;publishers&gt;</span>
    <span class="code-tag">&lt;xmllogger/&gt;</span>
  <span class="code-tag">&lt;/publishers&gt;</span>
<span class="code-tag">&lt;/project&gt;</span></pre>
</div></div>

<p>WinApp1 will be changed to the different project names. There are twelve projects in total - their names roughly match the names above (the arrows are changed to dashes). With this background, I can now begin to configure the security.</p>

<h4><a name="ScenarioOne-TurningOnSecurity"></a>Turning On Security</h4>

<p>First, I'm going to turn on security for the server. This involves adding a security block to the config file. Since there is only one security type defined so far, I've added a sessionSecurity element (this can be added anywhere within the config, as long as it is directly under the cruisecontrol element - i.e. it cannot be in a project or queue element). For the moment, I'll leave it with the default settings.</p>

<p>Running this config through the validator, I see that the security element needs an assertions element and a setting element, so I've added some blank instances of these. Now the config file passes validation and security has been turned on for the server. But, all this has done is completely lock down the server, so no one can do anything!</p>

<h4><a name="ScenarioOne-AddingSomeRolesandUsers"></a>Adding Some Roles and Users</h4>

<p>So the next thing to do is to add the users and roles. First, I've added the two roles - "Testers" and "Releasers". These are defined as follows:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;permissions&gt;</span>
  <span class="code-tag">&lt;rolePermission name=<span class="code-quote">"Testers"</span> forceBuild=<span class="code-quote">"Allow"</span> defaultRight=<span class="code-quote">"Deny"</span>/&gt;</span>
  <span class="code-tag">&lt;rolePermission name=<span class="code-quote">"Releasers"</span> forceBuild=<span class="code-quote">"Allow"</span> defaultRight=<span class="code-quote">"Deny"</span>/&gt;</span>
<span class="code-tag">&lt;/permissions&gt;</span></pre>
</div></div>

<p>Each of the roles has force build rights only, all other rights are still denied. Before I can add some people to the roles, I first need to add the users to the security. So I'm going to add four users, each with their own password (which are hard-coded for the moment).</p>

<p>So, now the security settings looks like this:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;permissions&gt;</span>
  <span class="code-tag">&lt;rolePermission name=<span class="code-quote">"Testers"</span> forceBuild=<span class="code-quote">"Allow"</span> defaultRight=<span class="code-quote">"Deny"</span>/&gt;</span>
  <span class="code-tag">&lt;rolePermission name=<span class="code-quote">"Releasers"</span> forceBuild=<span class="code-quote">"Allow"</span> defaultRight=<span class="code-quote">"Deny"</span>/&gt;</span>
<span class="code-tag">&lt;/permissions&gt;</span>
<span class="code-tag">&lt;users&gt;</span>
  <span class="code-tag">&lt;passwordUser name=<span class="code-quote">"bob"</span> display=<span class="code-quote">"Bob (Team Lead)"</span> password=<span class="code-quote">"bob1"</span>/&gt;</span>
  <span class="code-tag">&lt;passwordUser name=<span class="code-quote">"jane"</span> display=<span class="code-quote">"Jane (BA)"</span> password=<span class="code-quote">"jane2"</span>/&gt;</span>
  <span class="code-tag">&lt;passwordUser name=<span class="code-quote">"john"</span> display=<span class="code-quote">"John (QA)"</span> password=<span class="code-quote">"john3"</span>/&gt;</span>
  <span class="code-tag">&lt;passwordUser name=<span class="code-quote">"joe"</span> display=<span class="code-quote">"Joe (QA)"</span> password=<span class="code-quote">"joe4"</span>/&gt;</span>
<span class="code-tag">&lt;/users&gt;</span>
Next step is to add the users to the roles, so now the roles look like this:
<span class="code-tag">&lt;rolePermission name=<span class="code-quote">"Testers"</span> forceBuild=<span class="code-quote">"Allow"</span> defaultRight=<span class="code-quote">"Deny"</span>&gt;</span>
  <span class="code-tag">&lt;users&gt;</span>
    <span class="code-tag">&lt;userName name=<span class="code-quote">"john"</span>/&gt;</span>
    <span class="code-tag">&lt;userName name=<span class="code-quote">"joe"</span>/&gt;</span>
  <span class="code-tag">&lt;/users&gt;</span>
<span class="code-tag">&lt;/rolePermission&gt;</span>
<span class="code-tag">&lt;rolePermission name=<span class="code-quote">"Releasers"</span> forceBuild=<span class="code-quote">"Allow"</span> defaultRight=<span class="code-quote">"Deny"</span>&gt;</span>
  <span class="code-tag">&lt;users&gt;</span>
    <span class="code-tag">&lt;userName name=<span class="code-quote">"bob"</span>/&gt;</span>
    <span class="code-tag">&lt;userName name=<span class="code-quote">"jane"</span>/&gt;</span>
  <span class="code-tag">&lt;/users&gt;</span>
<span class="code-tag">&lt;/rolePermission&gt;</span></pre>
</div></div>

<p>Finally, I added a generic role for all the other uses:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;simpleUser name=<span class="code-quote">"*"</span>/&gt;</span></pre>
</div></div>

<p>This now gives me the roles and users. But, until CCTray and the dashboard are configured, they still can't do anything!</p>

<h4><a name="ScenarioOne-ConfiguringtheClients"></a>Configuring the Clients</h4>

<p>Configuring CCTray is done on the client-side. The user needs to go to settings, click on the Build Projects tab, and then click on "Add...". This will open up the list of servers - from here the user clicks on the server to modify and then clicks on "Configure". This will finally open up the security configuration:<br/>
<img src="download/attachments/28868718/CCTrayConfiguration.jpg" align="absmiddle" border="0"/></p>

<p>Here the user will need to check the "Server is secure" checkbox and then choose the authentication mode. Once they have done this they need to click on the "Configure" button and enter their credentials. Finally click on "Ok" all the way back to the main screen and security is now configured for CCTray.</p>

<p>Configuring the dashboard needs to be done at the server level instead. This involves opening dashboard.config and adding the following section underneath &lt;plugins&gt;:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;securityPlugins&gt;</span>
  <span class="code-tag">&lt;simpleSecurity/&gt;</span>
<span class="code-tag">&lt;/securityPlugins&gt;</span></pre>
</div></div>

<p>This adds a login section to the site, which allows the person to login with their username only. People with password secured accounts will fail to login. For this scenario this mode is fine for most people - the people in the other roles will need to use CCTray.</p>

<p>Now people can login and perform force builds, etc. However, the problem is everyone can force build any project! The next step is to configure the projects.</p>

<h4><a name="ScenarioOne-LockingDownProjects"></a>Locking Down Projects</h4>

<p>For the projects that are in the low security zone, there is no need to change the configuration. These will continue to work as-is.</p>

<p>For the remaining projects, I need to lock them down. This is done by adding a &lt;security&gt; element to the project element. At the moment there is only one type of security - defaultProjectSecurity. So to start with I added the following XML to the project element:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;security type=<span class="code-quote">"defaultProjectSecurity"</span> defaultRight=<span class="code-quote">"Deny"</span>/&gt;</span></pre>
</div></div>

<p>The defaultRight attribute is optional, but this changes the default permission so no-one can do anything on it. Of course, this isn't much use, so it's time to add in the permissions:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;security type=<span class="code-quote">"defaultProjectSecurity"</span> defaultRight=<span class="code-quote">"Deny"</span>&gt;</span>
  <span class="code-tag">&lt;assertions&gt;</span>
    <span class="code-tag">&lt;rolePermission name=<span class="code-quote">"Testers"</span> ref=<span class="code-quote">"Testers"</span>/&gt;</span>
    <span class="code-tag">&lt;rolePermission name=<span class="code-quote">"Releasers"</span> ref=<span class="code-quote">"Releasers"</span>/&gt;</span>
  <span class="code-tag">&lt;/assertions&gt;</span>
<span class="code-tag">&lt;/security&gt;</span></pre>
</div></div>

<p>This is the definition for a medium security zone project, the high security zone is similar, but without the Testers role in it.</p>

<p>And that's it! Security has now been configured for this scenario.</p>

<h4><a name="ScenarioOne-Credits"></a>Credits</h4>

<p>This scenario was originally posted on <a href="http://csut017.wordpress.com">Automated Coder</a></p>

				    					    <br/>
                        <div class="tabletitle">
                            <a name="attachments">Attachments:</a>
                        </div>

                        <div class="greybox" align="left">
                                                            <img src="images/icons/bullet_blue.gif" height="8" width="8" alt=""/>
                                <a href="download/attachments/28868718/CCTrayConfiguration.jpg">CCTrayConfiguration.jpg</a> (image/jpeg)
                                <br/>
                                                            <img src="images/icons/bullet_blue.gif" height="8" width="8" alt=""/>
                                <a href="download/attachments/28868718/Scenario1Overview.jpg">Scenario1Overview.jpg</a> (image/jpeg)
                                <br/>
                                                    </div>
				    
                    			    </td>
		    </tr>
	    </table>
	    <table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td height="12" background="http://confluence.public.thoughtworks.org//images/border/border_bottom.gif"><img src="images/border/spacer.gif" width="1" height="1" border="0"/></td>
			</tr>
		    <tr>
			    <td align="center"><font color="grey">Document generated by Confluence on Sep 29, 2009 20:59</font></td>
		    </tr>
	    </table>
    </body>
</html>